We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

ERROR | Model::find(array('order'=>'something')) | Syntax error, unexpected EOF

Errror:

  • Controller: dashboard
  • Action: index
  • Code Error: #0
  • Description: Syntax error, unexpected EOF
  • File: /home/wolf/Documents/BDP/Briefs/public_html/apps/models/entities/SettingMenu.php
  • Line: #62

DashboardController:

  public function indexAction ()

{ $menu = SettingMenu::find ( array ( "active = 1", 'order' => 'order', //NOT WORK //'limit' => 1, //WORK FINE. ) ) ; $this->view->menu = $menu; return TRUE; }

Model SettingMenu:

  namespace Modules\Models\Entities;

class SettingMenu extends \Phalcon\Mvc\Model { ......... ......... public static function find ( $parameters = array () ) { return parent::find ( $parameters ); // LINE# 62 } ......... ......... public function columnMap () { return array ( 'id' => 'id', 'name' => 'name', 'url' => 'url', 'description' => 'description', 'order' => 'order', 'active' => 'active', 'date_create' => 'date_create', 'date_update' => 'date_update' ); }



5.7k
Accepted
answer
edited Jan '15

Is this because order is a reserved keyword in the ORM?

Edit: I got the too early it appears, see @Phalcon's answer below for best answer.



33.8k

Reading the docs I see something like this:

'order' => 'order DESC'

Try specifying ASC or DESC.

If that truly is the entire content of your SettingMenu model, then you're missing a closing bracket } The error isn't being generated in the controller, it's being generated in the model.

edited Jan '15

If I excecute 'order ASC':

Syntax error, unexpected token ORDER, near to ' DESC', when parsing: SELECT [Modules\Models\Entities\SettingMenu].* FROM [Modules\Models\Entities\SettingMenu] WHERE active = 1 ORDER BY order DESC (126)

But, right now I know how to order. Thanks for information.

Reading the docs I see something like this:

'order' => 'order DESC'

Try specifying ASC or DESC.

edited Jan '15

SOLVED! I change the column name.

'order' => 'ordering DESC',

Is this because order is a reserved keyword in the ORM?

edited Jan '15

[SOLVED]

Wow! I try this and work fine.

If you still want to use 'order' as column name:

'order' => '[order] DESC',

https://docs.phalcon.io/en/latest/reference/phql.html#escaping-reserved-words